import React from 'react'
import { observer } from 'mobx-react';
import { withRouter } from 'react-router-dom';
import PopupBillNumberList from './PopupBillNumberList';
import PopupEditButton from './PopupEditButton';
import PopupListButton from './PopupListButton';
import WindowButton from './WindowButton';
import FnaSpecialStore from '../../stores/fnaSpecial/fnaSpecialStore'
import { Tools } from 'weaver-mobile';
const getLabel = Tools.getLabel;

@withRouter
@observer
export default class FnaSpecial extends React.Component {
   constructor(props) {
     super(props);
     this.state = {
      };
   }

   componentDidMount() {
   }

   componentWillReceiveProps(nextProps, nextState) {
    const location = this.props.location || {};
    const nextLocation = nextProps.location || {};
  }

   render() {
      const { history } = this.props;
      const {fnaParam,wfInfo,fieldObj,rowIndex,viewAttr,fieldValue,fieldid,detailKeyid,isDetailShow,isCardEdit} = this.props;
    	const requestid = wfInfo.requestid;
    	const type = fnaParam.type;
    	const nodeType = wfInfo.nodetype;
      const fnaSpecialStore = new FnaSpecialStore({ route: this.props.baseRoute,id:`field${fieldid}_${rowIndex}` });//不能放在WeaFna里面
    	let fieldGet = fnaParam.fieldGet;
    	let fieldSet = fnaParam.fieldSet;
      let detailList = fnaParam.detailList;
      let detailType = fnaParam.detailType;//区分借款和预付款
      let contentHtml = "";

    	switch(type){
            case 1://按钮弹出列表
              contentHtml = [
                            <PopupListButton
                              fnaSpecialStore={fnaSpecialStore}
                              detailRecordId={detailKeyid}
                              requestid={requestid}
                              //onClick={clickEvent}
                              isDetailShow={isDetailShow}
                              viewAttr={viewAttr}
                              wfInfo={wfInfo}
                              fieldObj={fieldObj}
                              fieldId={fieldid}
                              rowIndex={rowIndex}
                              isCardEdit={isCardEdit}
                            />];	
              break;
            case 2://按钮弹出编辑框
              contentHtml = (<PopupEditButton
                              fnaSpecialStore={fnaSpecialStore}
                              fieldId={fieldid}
                              fieldSet={fieldSet}
                              fieldGet={fieldGet}
                              rowIndex={rowIndex}
                              loanAmount={fieldValue}
                              viewAttr={viewAttr}
                              nodeType={nodeType}
                              wfInfo={wfInfo}
                              fieldObj={fieldObj}
                              showType={type}//标志是哪个组件
                              isDetailShow={isDetailShow}//标志是不是还没有点进明细
                              isCardEdit={isCardEdit}
                            />);

              break;
            case 3://按钮弹出新页面
              contentHtml = (<WindowButton
                              fnaSpecialStore={fnaSpecialStore}
                            />);
              break;
            case 5://单内序号列表
              contentHtml = [
                              <PopupBillNumberList	
                                fnaSpecialStore={fnaSpecialStore}
                                requestid={requestid}
                                fieldId={fieldid}
                                fieldGet={fieldGet}
                                fieldSet={fieldSet}
                                rowIndex={rowIndex}
                                detailList={detailList}
                                nodeType={nodeType}
                                wfInfo={wfInfo}
                                fieldObj={fieldObj}
                                dnxhValue={fieldValue}
                                viewAttr={viewAttr}
                                showType={type}//标志是哪个组件
                                isDetailShow={isDetailShow}//标志是不是还没有点进明细
                                detailType={detailType}
                                isCardEdit={isCardEdit}
                              />];
              break;
            default:
              contentHtml= "";
		}

 		return(
 			<div>
        {contentHtml}
			</div>
 		);
  }
}